package day8;

import com.sun.org.apache.xpath.internal.operations.String;
import org.junit.Test;

import java.io.File;

public class PractiseDemo2 {

    @Test
    public void test() {
        File file = new File("D:\\GZ2148班上课资料\\JAVASE\\第三周\\day11");
        recursiveFile(file);
    }

    private void recursiveFile(File file) {
        File[] files = file.listFiles();
        if (files.length == 0) {
            return;
        }

        StringBuilder sb = new StringBuilder("--");
        for (File file1 : files) {
            if (file1.isDirectory()) {
                System.out.println(sb + file1.getName());
                recursiveFile(file1);
            } else {
              sb.append("--");
                System.out.println(sb + file1.getName());
            }
        }
    }

    @Test
    public void test2() {
        File srcFile = new File("C:\\d1");
        File tarFile = new File("D:\\d1");

        recursiveFileCopy(srcFile, tarFile);
        System.out.println("复制完成");
    }

    private void recursiveFileCopy(File srcFile, File tarFile) {
        File[] files = srcFile.listFiles();
        if (!tarFile.exists()) {
            tarFile.mkdir();
        }

        if (files.length == 0) {
            return;
        }

        for (File file : files) {
            if (file.isDirectory()) {

            }
        }
    }
}
